Monadic Maps and Folds for Arbitrary Datatypes
نویسنده
چکیده
Each datatype constructor comes equiped not only with a so-called map and fold (catamorphism), as is widely known, but, under some condition, also with a kind of map and fold that are related to an arbitrary given monad. This result follows from the preservation of initiality under lifting from the category of algebras in a given category to a certain other category of algebras in the Kleisli category related to the monad.
منابع مشابه
Meta-Programming with Tabaluga
We present a lightweight approach to meta-programming in the functional programming language Haskell. In this approach, meta-programs are constructed with the help of generalised (possibly monadic) folds over the system of datatypes that represents the abstract syntax of the objectlanguage. Such folds are obtained by (1) reusing, refining, and combining basic fold algebras, and (2) feeding the ...
متن کاملDealing with Large Bananas
Many problems call for a mixture of generic and speci c programming techniques. We propose a polytypic programming approach based on generalised (monadic) folds where a separation is made between basic fold algebras that model generic behaviour and updates on these algebras that model speci c behaviour. We identify particular basic algebras as well as some algebra combinators, and we show how t...
متن کاملAn Implementation of Modular Monadic Semantics using Folds and Monadic Folds*
Modular monadic semantics can be implemented using folds or catamorphisms over a functor that expresses the abstract syntax of the language. By composing several functors, it is possible to obtain modular interpreters from reusable components. Monadic folds structure programs that process recursively their input and control the side effects of the output they produce. We consider that the seman...
متن کاملLISA : A Speci cation Language Based on WS 2
We integrate two concepts from programming languages into a speciication language based on WS2S, namely high-level data structures such as records and recursively-deened datatypes (WS2S is the weak second-order monadic logic of two successors). Our integration is based on a new logic whose variables range over record-like trees and an algorithm for translating datatypes into tree automata. We h...
متن کاملLISA: A Specification Language Based on WS2S
We integrate two concepts from programming languages into a speciication language based on WS2S, namely high-level data structures such as records and recursively-deened datatypes (WS2S is the weak second-order monadic logic of two successors). Our integration is based on a new logic whose variables range over record-like trees and an algorithm for translating datatypes into tree automata. We h...
متن کامل